'''
Created on May 16, 2011

@author: yev
'''

import logging
import logging.handlers

def create_logger(log_name, log_level = 'debug'):
    """
    inspired by http://www.sanxiago.com/programming/python-logging-module/
    """
    LEVELS = {'debug': logging.DEBUG,
          'info': logging.INFO,
          'warning': logging.WARNING,
          'error': logging.ERROR,
          'critical': logging.CRITICAL}
    log_level = LEVELS.get(log_level, logging.NOTSET)
    
    my_logger = logging.getLogger(log_name)
    my_logger.setLevel(log_level)
    handler = logging.StreamHandler()
    formatter = logging.Formatter("%(asctime)s - %(lineno)s - %(name)s - %(levelname)s - %(message)s")
    handler.setFormatter(formatter)
    my_logger.addHandler(handler)
    
    return my_logger
